package com.paper.tiger.easy.rpc.s.client.common;

/**
 * [简要描述]: rpc调用的服务端客户端通信类型
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/6/17 19:33
 * @since JDK 1.8
 */
public enum LetterType
{
    DOVE_REQUEST(0,"调用请求","DOVE_REQUEST"),
    DOVE_RESPONSE(1,"调用响应","DOVE_RESPONSE"),
    CHANNEL(2,"通道维护","CHANNEL"),

    HEART_BEAT(3,"心跳","heart_beat"),
    HEART_BEAT_RESP(4,"心跳相应","heart_beat_resp"),

    ;

    private final int code;

    private final String desc;

    private final String registerName;

    LetterType(int code, String desc, String registerName)
    {
        this.code = code;
        this.desc = desc;
        this.registerName = registerName;
    }

    public int getCode()
    {
        return code;
    }

    public String getDesc()
    {
        return desc;
    }

    public String getRegisterName()
    {
        return registerName;
    }

    public static LetterType getByCode(int code) {

        for (LetterType value : values())
        {
            if (value.code == code){
                return value;
            }
        }
        return null;
    }

}
